package java56_5;

public class Votor {
	static int count = 0;
	private String name;

	public Votor(String n) {
		name = n;
	}

	public void vote(String houxuanren) {
		if (count < 20) {
			System.out.println(name + "投给了" + houxuanren);
			count++;
			return;
		}
		System.out.println("投票人数已经达到上限！");
	}

	public static void main(String[] args) {
		for (int i = 1; i <= 30; i++) {
			Votor v = new Votor("王" + i);
			v.vote("奥巴马");
		}
		System.out.println("投了" + Votor.count);
	}
}
